<template>
  <div>
    <!-- 热歌榜  潘敏同学 -->
    <index></index>
    <div class="banner">
      <div class="mask"></div>
      <div class="pic">
        <div class="cloud"></div>
      </div>
      <p class="date">
        更新日期：{{ updataMonth > 9 ? updataMonth : "0" + updataMonth }}月{{
          updataDate1 > 9 ? updataDate1 : "0" + updataDate1
        }}日
      </p>
    </div>
    <div>
      <div
        v-for="(item, idx) in hotsList"
        :key="'search' + idx"
        class="song-list"
        @click="toPlay(item)"
      >
        <span :class="['rank', 'aa', { isred: idx < 3 }]">{{
          Number(idx + 1) > 9 ? Number(idx + 1) : "0" + Number(idx + 1)
        }}</span>

        <!-- 歌曲名 -->
       <!--  <div class="song-name"> -->
           <p class="song-name">{{ item.first }}</p>
          <!-- <router-link :to="'/play/' + item.id"> {{ item.first }}</router-link> -->
          <van-icon name="play-circle-o" class="start" />
        <!-- </div> -->
        <!-- sq样式 -->
        <i class="sq"></i>

      </div>
    </div>
  </div>
</template>

<script>
/* 引入头部组件 */
import index from "./index"
export default {
  data() {
    return {
      updataTime: "",
      updataMonth: "",
      updataDate1: "",
      hotSongList: [],
      hotsList: [],
      keyword: "",
    };
  },
  components:{
    index,
  },
  created() {
    this.getHotSong();
    this.getHot();
  },
  methods: {
    //获取热歌榜详情
    getHotSong() {
      this.$http("/top/list?idx=1")
        .then((res) => {
          this.updataTime = res.data.playlist.updateTime;
          let updataDate = new Date(this.updataTime);
          this.updataMonth = updataDate.getMonth() + 1;
          this.updataDate1 = updataDate.getDate();
        })
        .catch((err) => {
          console.log(err);
        });
    },

    //获取热歌榜列表
    getHot() {
      this.$http
        .get("/search/hot")
        .then((res) => {
          console.log(res.data.result.hots);
          this.hotsList = res.data.result.hots;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    //点击歌曲，跳转到歌曲播放界面
    toPlay(e){
       //跳转到播放界面
       console.log(e)
        /* this.$router.push("/play/"); */
    }
  },
};
</script>

<style scoped>
.banner {
  width: 100%;
  height: 180px;
  position: relative;
  overflow: hidden;
}
.mask {
  width: 100%;
  height: 180px;
  background: url(http://p2.music.126.net/GhhuF6Ep5Tq9IEvLsyCN7w==/18708190348409091.jpg);
  z-index: -1;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  background-repeat: no-repeat;
  background-size: cover;
  filter: blur(20px);
  transform: scale(1.5);
}
.banner .pic {
  top: 25%;
  bottom: 0;
  z-index: 2;
  padding-left: 20px;
  box-sizing: border-box;
  position: relative;
}
.cloud {
  width: 168px;
  height: 82px;
  background: url(/static/img/index_icon_2x.png) no-repeat;
  background-position: -28px -33px;
  background-size: 168px 112px;
}
.date {
  height: 50px;
  width: 170px;
  margin-top: 55px;
  margin-left: 20px;
  color: white;
}

/* 热歌榜--单曲 */
.song-list {
  height: 60px;
  border-bottom: 1px solid #f4f4f4;
  font-size: 15px;
  padding-left: 40px;
  position: relative;
}
p{
 margin:0;
}
.rank {
  position: absolute;
  top: 0;
  left: 8px;
  font-size: 18px;
  line-height: 40px;
}

.isred {
  color: #f00;
}

.sq {
  /* 不独占一行的块级元素 */
  display: inline-block;
  width: 14px;
  height: 10px;
  background-image: url("../../static/img/index_icon_2x.png");
  background-size: 186.75px 109.125px;
  background-position: 0 0;
}
.start {
  font-size: 30px;
  color: gray;
  margin-right: 10px;
  
  margin-bottom: 10px;
  position: absolute;
   right: 10px;
   top: 20px;
}
.song-name {
  font-size: 16px;
  width: 50%;
  padding: 10px 0 10px 0;
}
</style>